package org.beanutopia;

import com.google.common.base.Function;

/**
 * @author: Yardena
 * @date: Oct 27, 2009 2:11:19 PM
 */
public abstract class ComputedProperty<B,V> extends AbstractProperty<B,V> {
  private static final long serialVersionUID = 3426329601739915753L;
  private final Function<B,V> function;
  public ComputedProperty(Function<B,V> f, V defaultValue) {
    super(defaultValue);
    function = f;
  }
  public ComputedProperty(Function<B,V> f) {
    this(f, null);
  }
  @Override protected void init() {}
  @Override protected V get(B object) {
    return function.apply(object);
  }

}
